package cn.yunhe.servlet;

import cn.yunhe.service.NewsService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class GetJsonNewsServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  response.setContentType("text/json;charset=UTF-8");
        PrintWriter out =response.getWriter();
        NewsService newsService=new NewsService();
        JSONObject jsonObject=new JSONObject();
        JSONArray jsonArray=newsService.getNewsJsonArray();
        out.print(jsonArray);



    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }
}
